package android.framework.binding;

import java.util.ArrayList;
import java.util.List;

public class ListMultiBindingAdapter<T> implements IListObserver<T> {

	private List<IListObserver<T>> observers = new ArrayList<IListObserver<T>>();
	
	public void addObserver(IListObserver<T> observer){
		if(!observers.contains(observer)){
			observers.add(observer);
		}
	}
	
	public boolean removeObserver(IListObserver<T> observer){
		if(observers.contains(observer)){
			return observers.remove(observer);
		}
		return false;
	}
	
	public boolean onListChanged(T item, ListChangeOperation changeOperation,
			long actionId) {
		boolean result = false;
		for (IListObserver<T> observer : observers) {
			result |= observer.onListChanged(item, changeOperation, actionId);
		}
		return result;
	}

}
